package com.medistat.model;

import java.util.Calendar;

import javax.persistence.Basic;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.GenericGenerator;

import com.medistat.model.enums.TypeOfFreeDay;

@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn (name="freeday_type", discriminatorType=DiscriminatorType.STRING)
@Entity
public class FreeDay extends StandardPersistentObject {

	@Id @GeneratedValue(generator="ID_GENERATOR_FOR_FREEDAY")
	@GenericGenerator(name="ID_GENERATOR_FOR_FREEDAY", strategy = "increment")
	private Long id;
	
	//parent - back reference
	@ManyToOne(targetEntity=Person.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="PersonID", referencedColumnName="ID") })	
	@Basic(fetch=FetchType.LAZY)
	private Person person;
	
	private Calendar dateFrom;
	private Calendar dateTo;
	private TypeOfFreeDay outOfWork;
	
	@Override
	public Long getId() {
		return this.id;
	}

	public Calendar getDateFrom() {
		return dateFrom;
	}

	public void setDateFrom(Calendar date) {
		this.dateFrom = date;
	}
	
	public Calendar getDateTo() {
		return dateTo;
	}

	public void setDateTo(Calendar dateTo) {
		this.dateTo = dateTo;
	}

	public TypeOfFreeDay getOutOfWork() {
		return outOfWork;
	}

	public void setOutOfWork(TypeOfFreeDay outOfWork) {
		this.outOfWork = outOfWork;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}
}
